<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <h2>水果店</h2>
        <ul>
            <li v-for="item in arr" :key = 'item.id'>
                <span>{{item.name}}</span>
                <span>{{item.price}}</span>
                <button @click="del(item.id)">delete</button>
            </li>
        </ul>
    </div>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                arr: [
                    {
                        id: 1,
                        name: 'apple',
                        price: 10
                    },
                    {
                        id: 2,
                        name: 'banana',
                        price: 18
                    },
                    {
                        id: 3,
                        name: 'pear',
                        price: 3
                    }
                ]
            },methods:{
                del(n){
                    this.arr = this.arr.filter(item =>item.id !== n)
                }
            }
        });
    </script>
</body>

</html>